/**
 * 新增时间：2009-12-2
 * 朱家进
 * 内容：厅所属区县相互切换
 * 
 */
package com.zjht.gmcc.servlet.sys;

import java.io.PrintWriter;
import java.sql.PreparedStatement;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zjht.gmcc.bean.BaseServlet;
import com.zjht.gmcc.bean.util.InitParam;
import com.zjht.gmcc.bean.util.MyJDBC;

public class OrgaEditArea extends BaseServlet {

	private static final long serialVersionUID = 1L;

	public boolean process(HttpServletRequest request, HttpServletResponse response, HttpSession session, PrintWriter out, MyJDBC myJDBC, String menu)
			throws Exception {

		int flag = 0;
		String act = null;
		PreparedStatement ps = null;
		String orgaCode = request.getParameter("orgaCode");
		// String channelType = request.getParameter("channelType");
		String orgaName = request.getParameter("orgaName");
		String parentOrgaCode = request.getParameter("parentOrgaCode");// 新的区县公司编码
		String channelType = request.getParameter("channelType2");

		String sql = "UPDATE organiza SET parentorgacode = ? WHERE orgacode = ?";
		ps = myJDBC.prepareStatement(sql);
		ps.setString(1, parentOrgaCode);
		ps.setString(2, orgaCode);
		flag = ps.executeUpdate();

		act = orgaName + " 切换区县公司";

		if (flag == 1) {
			InitParam.initOrgaInfo();
			alertOK(out, act + "成功！", "dialogArguments.location.href='orga/orga.jsp?orgacode=" + orgaCode + "&channelType=" + channelType
					+ "&orgaType=4';window.returnValue='" + orgaCode + "';window.close();");
		} else {
			errAlert(request, out, menu, act + "失败");
		}
		return flag > 0;
	}
}
